#include "HeightmapWriter.h"

HeightmapWriter::HeightmapWriter()
{
	//
}

HeightmapWriter::~HeightmapWriter()
{
	//
}

void HeightmapWriter::write(int** map, int h, int w)
{
	//
	int x,y, i, cell;
	pngwriter png(h * BOX_TO_PIXEL, w * BOX_TO_PIXEL ,0,"heightmap.png");
	double r, g, b;
	for(y = 0; y < h; y++)
	{
		for(x = 0; x < w; x++)
		{	
			//printf("Pixel R: %f, G: %f, B: %f\n @ (%d, %d)", r, g, b, x, y);
			
			//cell = map[(y * w) + x];
			cell = *(*(map + x ) + y);
			if(cell == 1)
			{
				png.plot(x + 1, y + 1, 0.0, 0.0, 0.0);
			}
			else if(cell == 2)
			{
				png.plot(x + 1, y + 1, 1.0, 0.0, 0.0);
			}
			else if (cell == 0)
			{
				png.plot(x + 1, y + 1, 1.0, 1.0, 1.0);
			}
		}
	}
	png.close();
	return;
}